#include "Explosion.h"

#include "../../engine/core/Global.h"

Explosion::Explosion(glm::vec3 position) : GameObject("explosion", position) {
    time = 0.0f;
}

Explosion::~Explosion() {

}

void Explosion::addTime(float dt) {
    time += dt;

    if(time > 1.0f) {
        Global::getWorld()->deleteLater.push_back(this);
    }
}

void Explosion::createExplosions() {
    for(int i = 0; i < 20; i++) {
        GameObject* explosion = new GameObject("explosion");

        explosion->setMesh(Mesh::load("game/assets/models/smallParticle.obj"));
        explosion->setColorMap(Texture::load("game/assets/textures/yellow.jpg"));
        explosion->setLocation(glm::normalize(glm::vec3(Global::randomFloat(-10, 10), Global::randomFloat(-10, 10), Global::randomFloat(-10, 10))));

        children.push_back(explosion);
    }
}

void Explosion::accept(Visitor* visitor) {
    visitor->visit(this);
}
